package request

import "github.com/astaxie/beego/validation"

type PickAddrRequest struct {
	AddrId     uint   `json:"addrId"`                        //主键
	AddrName   string `json:"addrName" binding:"required"`   //自提点名称 必填
	Addr       string `json:"addr" binding:"required"`       //地址 必填
	Area       string `json:"area" binding:"required"`       //区 必填
	AreaId     uint   `json:"areaId" binding:"required"`     //区id 必填
	City       string `json:"city" binding:"required"`       //市 必填
	CityId     uint   `json:"cityId" binding:"required"`     //市id 必填
	Mobile     string `json:"mobile" binding:"required"`     //手机号 必填
	Province   string `json:"province" binding:"required"`   //省份 必填
	ProvinceId uint   `json:"provinceId" binding:"required"` //省份id 必填
	//ShopId     int    `json:"shopId"`//当前单商户这个字段暂不使用
}

func (p *PickAddrRequest) Valid(v *validation.Validation) {
	if p.AddrName == "" {
		v.SetError("AddrName", "自提点名称不能为空")
	} else if p.Addr == "" {
		v.SetError("Addr", "地址不能为空")
	} else if p.Mobile == "" {
		v.SetError("Mobile", "手机号不能为空")
	} else if p.Province == "" {
		v.SetError("Province", "省份不能为空")
	} else if p.ProvinceId == 0 {
		v.SetError("ProvinceId", "省份不能为空")
	} else if p.City == "" {
		v.SetError("City", "城市不能为空")
	} else if p.CityId == 0 {
		v.SetError("CityId", "城市不能为空")
	} else if p.Area == "" {
		v.SetError("Area", "区/县不能为空")
	} else if p.AreaId == 0 {
		v.SetError("AreaId", "区/县不能为空")
	}
}
